import Vue from 'vue'
import App from './App.vue'
import './registerServiceWorker'
import router from './router'

import './assets/css/global.css'
import './assets/css/reset.css'

Vue.config.productionTip = false

//导入ElementUI
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

Vue.use(ElementUI);

//引入axios
import axios from "axios";
import Cookies from "js-cookie";
import vueshowpdf from "vueshowpdf";
//绑定一个基础地址
axios.defaults.baseURL = "http://localhost:9191/" ;
//绑定到Vue上,这样在任何组件中都可以使用$axios对象
Vue.prototype.$axios = axios;
//全局使用cookie
Vue.prototype.$cookies = Cookies;
Vue.prototype.vueshowpdf = vueshowpdf;

//配置axios
axios.interceptors.request.use((config)=>{

  console.log(config)

  //尝试将本地token加入到请求头中
  //從Cookies裡拿到token
  let token = Cookies.get('user');
  if(token){
    config.headers['token']=token;
    document.cookie = "user = "+token;
  }

  return config
})


new Vue({
  router,
  render: h => h(App)
}).$mount('#app')















